<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <script src="https://cdn.bootcss.com/jquery/3.3.1/jquery.min.js"></script>
    <title>JSONP</title>

    <script type="text/javascript">
        function jsonpget() {
            $.ajax({
                url: 'http://127.0.0.1:8080/getUserMsgJsonp',
                type: 'post',
                dataType:'jsonp',
                jsonp: "callback",
                data: { "userId":1},
                success:function(data){
                    alert(data.id+" "+data.name +"");
                    $("#id").val(data.id);
                    $("#name").val(data.name);
                    $("#aa").show();
                },
                error:function(data){
                    $('#mstr_ck').html("获取验证码失败，请重试！");
                }
            });
        }

        function aa() {
            $.ajax({
                url: 'http://127.0.0.1:8081/getUserMsgJsonp',
                type: 'post',
                dataType:'json',
                data: { "userId":1},
                success:function(data){
                    alert(data.id+" "+data.name +"");
                    $("#id").val(data.id);
                    $("#name").val(data.name);
                    $("#aa").show();
                },
                error:function(data){
                    $('#mstr_ck').html("获取验证码失败，请重试！");
                }
            });
        }
    </script>
</head>
<body>
this is index page.
<br>
<a href="javascript:void(0);" onclick="jsonpget()">jsonp获取</a>
<br>
<a href="javascript:void(0);" onclick="aa()">非jsonp获取</a>

<div id="aa" style="display: none">
    id:<input id="id"/>
    用户名:<input id="name"/>
</div>
</body>
</html>